<?php //allow users to uload personal photo to the server
 $page_title='Upload a photo';
 session_start();
 $u_id=$_SESSION['u_id'];
 
 require_once( 'util.php' );

 if (isset($_POST['submitted'])) {
 
		$filename='photo';
		
		if (isset($_FILES[$filename]) && ($_FILES[$filename]['error'] != 4)) {
            if (move_uploaded_file($_FILES[$filename]['tmp_name'], "./userphoto/$u_id")){
                alert_and_redirect( '文件上传成功', 'information_reset.php' );
            } else {					
                alert_and_redirect( '文件上传失败', 'information_reset.php' );
            }
		}
		else {
			alert_and_redirect( '请选择有效文件', 'information_reset.php' );
		}
    } else {
        alert_and_redirect( '请选择有效文件', 'information_reset.php' );
    }

?>